<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>vue</title>
  <script src="./js/vue.js"></script>
</head>

<body>
  <div id="app">
    <!-- 对象 -->
    <div :style="obj">香椿好不好吃，吃了才知道</div>
    <!-- <div :style="{color:'blue',fontSize:'30px'}">香椿好不好吃，吃了才知道</div> -->
    <div :style="{color:'blue'}">香椿好不好吃，吃了才知道</div>
    <button @click="addStyle">添加一个样式</button>

    <hr>
    <!-- 数组方式 -->
    <div :style="[{color:'red'},{fontSize:'60px'}]">香椿好不好吃，吃了才知道</div>
    <div :style="arr">香椿好不好吃，吃了才知道</div>


  </div>

  <script>

    new Vue({
      el: '#app',
      data: {
        obj: { color: 'blue' },
        arr: [{ color: 'red' }, { fontSize: '60px' }]
      },
      methods: {
        addStyle() {
          this.$set(this.obj, 'fontSize', '30px')
        }
      }
    })
  </script>
</body>

</html>